package com.huang.gateway.utils;


import com.huang.entity.result.HStringResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.*;

/**
 * @author HuangShen
 * @Description
 * @create 2021-09-10 13:37
 */
public class AsyncSendRequestUtils {

    private static final Logger logger = LoggerFactory.getLogger(AsyncSendRequestUtils.class);
    private static final ExecutorService executorService = Executors.newFixedThreadPool(20);

    public static <T> HStringResult<T> send(Callable<HStringResult<T>> task) {
        HStringResult<T> result = null;
        try {
             result = executorService.submit(task).get();
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
        return result;
    }
}
